<%@ page import="com.fhd.constant.Constants" %>
<%@ page import="com.fhd.pojo.Merchant" %>
<%@ page import="com.mysql.cj.util.StringUtils" %>
<%@ page import="com.fhd.pojo.House" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.fhd.service.Client.ClientService" %>
<%@ page import="com.fhd.pojo.Client" %><%--
  Created by IntelliJ IDEA.
  User: 44252
  Date: 2025/4/2
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>店铺详情</title>
</head>
<body>
<h2>店铺信息如下：</h2>
<%--退出去的时候要把两个Session去掉--%>
<a href="<%=request.getContextPath()%>/client.do?method=closeClientVisitMerchantSession">返回</a>
<br><br>
<%
    // 得到商户信息
    Merchant merchant = (Merchant) request.getSession().getAttribute(Constants.CLIENT_VISIT_MERCHANT_INFORMATION_SESSION);
    out.print("店铺名：" + merchant.getShopName() + "<br>");
    out.print("联系电话：" + merchant.getPhone() + "<br>");
    out.print("关键词：" + merchant.getKeyWord() + "<br>");
    out.print("工作时间：" + merchant.getWorkTimeBegin() + "~~~" + merchant.getWorkTimeEnd() + "<br>");
    int openSituation = merchant.getOpenSituation();
    if (openSituation == 0) {
        out.print("营业状态：未营业" + "<br>");
    } else {
        out.print("营业状态：营业中" + "<br>");
    }
    out.print("创建日期：" + merchant.getCreateDate() + "<br>");
%>
<br>
<h2>该店铺房型信息如下：</h2>
<%
    //得到房型及返回信息
    String object = (String)request.getSession().getAttribute(Constants.CLIENT_VISIT_MERCHANT_MESSAGE);
    if (!StringUtils.isNullOrEmpty(object)) {
        // 没有房型
        out.print("<h2 style=\"color: red\">" + object + "</h2>");
        request.getSession().removeAttribute(Constants.CLIENT_VISIT_MERCHANT_MESSAGE);
    } else {
        // 有房型
        ArrayList<House> houses = (ArrayList<House>) request.getSession().getAttribute(Constants.CLIENT_VISIT_MERCHANT_HOUSE_SESSION);
        for (House house : houses) {
            out.print("房型名：" + house.getHouseName() + "<br>");
            out.print("关键词：" + house.getKeyWord() + "<br>");
            out.print("价格：" + house.getPrice() + "<br>");
            out.print("剩余数量：" + house.getRemainNumber() + "<br>");
%>
<br>
<%--下单情况--%>
<form action="<%=request.getContextPath()%>/client.do" method="post">
    <input type="hidden" name="method" value="clientPlaceOrder">
    <input type="hidden" name="clientId" value="<%=((Client)request.getSession().getAttribute(Constants.CLIENT_SESSION)).getId()%>">
    <input type="hidden" name="merchantId" value="<%=merchant.getId()%>">
    <input type="hidden" name="houseId" value="<%=house.getId()%>">
    <input type="hidden" name="price" value="<%=house.getPrice()%>">
    <label for="number">下单数目：</label>
    <input type="number" name="number" id="number" max="<%=house.getRemainNumber()%>" required min="1">
    <label for="startTime">开始时间：</label>
    <input type="date" name="startTime" id="startTime" required>
    <label for="endTime">结束时间：</label>
    <input type="date" name="endTime" id="endTime" required>
    <input type="submit" value="下单">
</form>
<%
            out.print("=========================================<br>");
        }
    }

%>

</body>
</html>
